package org.micservice.config;

import org.micservice.ResultMap;
import org.micservice.User;
import org.micservice.service.CustomerService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class CustomerServiceException implements FallbackFactory<CustomerService> {

    @Override
    public CustomerService create(Throwable cause) {
        return new CustomerService() {
            @Override
            public ResultMap getUsers() {
                ResultMap resultMap = new ResultMap();
                resultMap.setCode(-1);
                resultMap.setMsg("查询用户熔断");
                return resultMap;
            }

            @Override
            public ResultMap addUser(User user) {
                ResultMap resultMap = new ResultMap();
                resultMap.setCode(-1);
                resultMap.setMsg("添加用户熔断");
                return resultMap;
            }
        };
    }
}
